package com.zqx.visitor.objectstruct;

import com.sun.org.apache.bcel.internal.generic.NEW;
import com.zqx.visitor.abstractelement.Employee;
import com.zqx.visitor.abstractvisitor.Department;

import java.util.ArrayList;

/**
 * description: 对象结构
 * @author zqx
 * @date 2018/09/04
 */
public class EmployeeList {
    //定义一个集合用于存储员工对象
    private ArrayList<Employee> list = new ArrayList<Employee>();

    public void addEmployee(Employee employee){
        list.add(employee);
    }

    //遍历访问员工集合中的每一个员工对象
    public void accpet(Department handler){
        for (Object obj:list){
            ((Employee)obj).accept(handler);
        }
    }
}
